package exam.web.action;

import java.util.List;

import exam.common.util.KeyCommon;
import exam.common.util.NullCheckUtil;
import exam.model.entity.TAnswerEntity;
import exam.web.action.base.QuestionActionBase;

/**
 * <p>ViewQuestionAction</p>
 * 
 * @author PhongTN
 * @version 02/05/2012
 */
public class ViewQuestionAction extends QuestionActionBase {

	private static final long serialVersionUID = 1L;
	
	private List<TAnswerEntity> listAnswerEntity;

	@Override
	public String execute() throws Exception {
		String questionId = request.getParameter(KeyCommon.QUESTION_ID);
		if (NullCheckUtil.isNUll(questionId)) {
			return ERROR;
		}
		super.settQuestionEntity(questionDAO.selectByPk(Long.valueOf(questionId)));
		listAnswerEntity = answerDAO.selectByQuestionId(gettQuestionEntity().getQuestionId());
		return SUCCESS;
	}
	
	public List<TAnswerEntity> getListAnswerEntity() {
		return listAnswerEntity;
	}
	
	public void setListAnswerEntity(List<TAnswerEntity> listAnswerEntity) {
		this.listAnswerEntity = listAnswerEntity;
	}
}
